clc;
clear;
close all;

 
load inflation_stat;
close all  
set(gca,'FontSize',10)
set(gcf,'PaperUnits','inches');
set(gcf,'PaperSize', [10 8]);
set(gcf,'PaperPosition',[0 0 10 8]);
set(gcf,'PaperPositionMode','Manual'); 


datestart = datetime(1963,03,31);
dates  = dateshift(datestart,'end','quarter',0:227)';  

% Plot raw series
figure(1) 
titles = {'Headline','Core','Food','Energy'};
for iplot = 1:4
subplot(2,2,iplot)
 plot(dates(3:end),ShocksVAR_temp(:,iplot ) ,'Linewidth',1  );
    title(titles(:,iplot ))
    if iplot <4
    ylim([-20 20])
    end
    line(dates,zeros(228,1),'color','k')
end

print -dpdf -r1000 Figure_1.pdf  
print -depsc -r1000 Figure_1.eps 



%% 8 portfolios
clear
close all 


% 3. Expected return: 7 assets 
load asset_1_real;
load asset_2_real;
beta_core_35 = beta_plot_35(:,6);
beta_energy_35 = beta_plot_35(:,8);
beta_headline_35 = beta_plot_35(:,3);

averagereturn = beta_plot(:,1);
averagereturn_35 = beta_plot_35(:,1);
 
figure(2)

set(gca,'FontSize',10)
set(gcf,'PaperUnits','inches');
set(gcf,'PaperSize', [10 8]);
set(gcf,'PaperPosition',[0 0 10 8]);
set(gcf,'PaperPositionMode','Manual'); 

subplot(2,2,1)
scatter(pre_ret_headline,averagereturn,'filled');
box on;
names = char('Stock','Treasury','Agency','Corporate','Currency','Commodity','Reits','Intl');

for k = 1:8
text(pre_ret_headline(k)+0.1,averagereturn(k)+0.1,names(k,:),'color','black','Fontsize',10); 
end
ylabel('average excess return') 
xlabel('model predicted return') 
title('Headline: 8 average portfolios','Fontsize',12)
ylim([-1 9])
xlim([ -2 3 ])

subplot(2,2,3)
label = char('s1','s2','s3','s4','s5','t1','t2','t3','t4','t5','t6','t7',...
    'a1','a2','a3','a4','cp1','cp2','cp3','cp4','fx1','fx2','fx3','fx4','fx5','fx6','fx7',...
    'cm1','cm2','cm3','cm4','cm5','re1','re2','re3','in1','in2','in3');
box on; 
hold on
scatter(pre_ret_headline_35(1:5),averagereturn_35(1:5),'filled');
scatter(pre_ret_headline_35(6:12),averagereturn_35(6:12),'filled');
scatter(pre_ret_headline_35(13:16),averagereturn_35(13:16),'filled');
scatter(pre_ret_headline_35(17:20),averagereturn_35(17:20),'filled');
scatter(pre_ret_headline_35(21:27),averagereturn_35(21:27),'filled');
scatter(pre_ret_headline_35(28:32),averagereturn_35(28:32),'filled');
scatter(pre_ret_headline_35(33:35),averagereturn_35(33:35),'filled');
scatter(pre_ret_headline_35(36:38),averagereturn_35(36:38),'filled','MarkerFaceColor',[0 .32 .32],'MarkerEdgeColor',[0 .32 .32]);

for k = 1:38
text(pre_ret_headline_35(k)+0.01,averagereturn_35(k)+0.1,label(k,:),'color','black','Fontsize',10); 
end
hold off
ylabel('average excess return') 
xlabel('model predicted return') 
title('Headline: 38 portfolios','Fontsize',12)
ylim([-2 10])
xlim([ -2 3 ]) 


subplot(2,2,2)
scatter(pre_ret,averagereturn,'filled');
box on;
names = char('Stock','Treasury','Agency','Corporate','Currency','Commodity','Reits','Intl');
for k = 1:8
text(pre_ret(k)+0.2,averagereturn(k)+0.1,names(k,:),'color','black','Fontsize',10); 
end
ylabel('average excess return') 
 xlabel('model predicted return') 
title('Core and energy: 8 average portfolios','Fontsize',12)
ylim([-2 10])
xlim([-2 12 ])

subplot(2,2,4)
label = char('s1','s2','s3','s4','s5','t1','t2','t3','t4','t5','t6','t7',...
    'a1','a2','a3','a4','cp1','cp2','cp3','cp4','fx1','fx2','fx3','fx4','fx5','fx6','fx7',...
    'cm1','cm2','cm3','cm4','cm5','re1','re2','re3','in1','in2','in3');
box on; 
hold on
scatter(pre_ret_35(1:5),averagereturn_35(1:5),'filled');
scatter(pre_ret_35(6:12),averagereturn_35(6:12),'filled');
scatter(pre_ret_35(13:16),averagereturn_35(13:16),'filled');
scatter(pre_ret_35(17:20),averagereturn_35(17:20),'filled');
scatter(pre_ret_35(21:27),averagereturn_35(21:27),'filled');
scatter(pre_ret_35(28:32),averagereturn_35(28:32),'filled');
scatter(pre_ret_35(33:35),averagereturn_35(33:35),'filled');
scatter(pre_ret_35(36:38),averagereturn_35(36:38),'filled','MarkerFaceColor',[0 .32 .32],'MarkerEdgeColor',[0 .32 .32]);

for k = 1:38
text(pre_ret_35(k)+0.1,averagereturn_35(k)+0.1,label(k,:),'color','black','Fontsize',10); 
end
hold off

 ylabel('average excess return') 
xlabel('model predicted return') 
title('Core and energy: 38 portfolios','Fontsize',12)
ylim([-2 10])
xlim([-2 12])
legend('Stock (s)','Treasury (t)','Agency (a)','Corporate (cp)','Currency (fx)','Commodity (cm)','REITs (re)','Intl (in)','Location','southeast');
 

print -dpdf -r1000 Figure_2.pdf  
print -depsc -r1000 Figure_2.eps 



%% 35 portfolios

figure(3)

set(gca,'FontSize',10)
set(gcf,'PaperUnits','inches');
set(gcf,'PaperSize', [6 8]);
set(gcf,'PaperPosition',[0 0 6 8]);
set(gcf,'PaperPositionMode','Manual'); 

subplot(3,1,1) 
label = char('s1','s2','s3','s4','s5','t1','t2','t3','t4','t5','t6','t7',...
    'a1','a2','a3','a4','cp1','cp2','cp3','cp4','fx1','fx2','fx3','fx4','fx5','fx6','fx7',...
    'cm1','cm2','cm3','cm4','cm5','re1','re2','re3','in1','in2','in3');
box on; 
hold on
scatter(beta_headline_35(1:5),averagereturn_35(1:5),'filled');
scatter(beta_headline_35(6:12),averagereturn_35(6:12),'filled');
scatter(beta_headline_35(13:16),averagereturn_35(13:16),'filled');
scatter(beta_headline_35(17:20),averagereturn_35(17:20),'filled');
scatter(beta_headline_35(21:27),averagereturn_35(21:27),'filled');
scatter(beta_headline_35(28:32),averagereturn_35(28:32),'filled');
scatter(beta_headline_35(33:35),averagereturn_35(33:35),'filled');
scatter(beta_headline_35(36:38),averagereturn_35(36:38),'filled','MarkerFaceColor',[0 .32 .32],'MarkerEdgeColor',[0 .32 .32]);

for k = 1:38
text(beta_headline_35(k)+0.1,averagereturn_35(k)+0.1,label(k,:),'color','black','Fontsize',10); 
end
hold off


ylabel('average excess return') 
xlabel('beta') 
title('Headline')
ylim([-2 10])
xlim([-10 20]) 

subplot(3,1,2) 
box on; 
hold on
scatter(beta_core_35(1:5),averagereturn_35(1:5),'filled');
scatter(beta_core_35(6:12),averagereturn_35(6:12),'filled');
scatter(beta_core_35(13:16),averagereturn_35(13:16),'filled');
scatter(beta_core_35(17:20),averagereturn_35(17:20),'filled');
scatter(beta_core_35(21:27),averagereturn_35(21:27),'filled');
scatter(beta_core_35(28:32),averagereturn_35(28:32),'filled');
scatter(beta_core_35(33:35),averagereturn_35(33:35),'filled');
scatter(beta_core_35(36:38),averagereturn_35(36:38),'filled','MarkerFaceColor',[0 .32 .32],'MarkerEdgeColor',[0 .32 .32]);

for k = 1:38
text(beta_core_35(k)+0.1,averagereturn_35(k)+0.1,label(k,:),'color','black','Fontsize',10); 
end
hold off
ylabel('average excess return') 
xlabel('beta') 
title('Core')
ylim([-2 10])
xlim([-10 4])

subplot(3,1,3) 
box on; 
hold on
scatter(beta_energy_35(1:5),averagereturn_35(1:5),'filled');
scatter(beta_energy_35(6:12),averagereturn_35(6:12),'filled');
scatter(beta_energy_35(13:16),averagereturn_35(13:16),'filled');
scatter(beta_energy_35(17:20),averagereturn_35(17:20),'filled');
scatter(beta_energy_35(21:27),averagereturn_35(21:27),'filled');
scatter(beta_energy_35(28:32),averagereturn_35(28:32),'filled');
scatter(beta_energy_35(33:35),averagereturn_35(33:35),'filled');
scatter(beta_energy_35(36:38),averagereturn_35(36:38),'filled','MarkerFaceColor',[0 .32 .32],'MarkerEdgeColor',[0 .32 .32]);

for k = 1:38
text(beta_energy_35(k)+0.03,averagereturn_35(k)+0.1,label(k,:),'color','black','Fontsize',10); 
end
ylabel('average excess return') 
xlabel('beta') 
title('Energy')
ylim([-2 10])
xlim([-1 4])
legend('Stock (s)','Treasury (t)','Agency (a)','Corporate (cp)','Currency (fx)','Commodity (cm)','REITs (re)','Intl (in)','Location','southeast');

hold off
%print -painters -dpdf -r1000 Figure_3_2024.pdf

print -dpdf -r1000 Figure_3.pdf  
print -depsc -r1000 Figure_3.eps 


%% announcement plot

load data_announcement_plot.mat
figure(4)
set(gca,'FontSize',10)
set(gcf,'PaperUnits','inches');
set(gcf,'PaperSize', [10 3.5]);
set(gcf,'PaperPosition',[0 0 10 3.5]);
set(gcf,'PaperPositionMode','Manual'); 


a1 = 1:4; 
a2 = 5:5+3;
a3 = 9:9+5;
a4 = 15:15+3;


namelist = char('sp500' ,'sp400','nasdaq','russell','2y','5y','10y','20y','aud','cad','eur','jpy','chf','gbp','oil'  ,'corn','cattle','gold');  
Y = mean_rx;  
subplot(1,2,1)
X = beta_bi(1:end,3) ; 
hold on
scatter(X(a1),Y(a1),'filled');
scatter(X(a2),Y(a2),'filled');
scatter(X(a3),Y(a3),'filled');
scatter(X(a4),Y(a4),'filled');
for k = 1:size(X,1)
text(X(k,1)+0.03,Y(k,1)-0.01,namelist(k,:),'color','black','Fontsize',8); 
end 
box on
ylabel('average return')
xlabel('beta')
hold off
title(append('Headline' ))
xlim([-1.1 0.3])

subplot(1,2,2)
X= beta_bi(1:end,1) ; 
hold on
scatter(X(a1),Y(a1),'filled');
scatter(X(a2),Y(a2),'filled');
scatter(X(a3),Y(a3),'filled');
scatter(X(a4),Y(a4),'filled');
for k = 1:size(X,1)
text(X(k,1)+0.03,Y(k,1)-0.01,namelist(k,:),'color','black','Fontsize',8); 
end 
box on
ylabel('average return')
xlabel('beta')
hold off
xlim([-2.1 0.3]) 
title(append('Core'))



print -dpdf -r1000 Figure_4.pdf  
print -depsc -r1000 Figure_4.eps 


